<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 4rem;
            height: 4rem;
            background-color: #f99;
        }
    </style>
</head>

<body>

    <div></div>

    <script>
        //rem适配原理
        //750 50px
        //320最小屏幕
        (function() {
            window.onresize = function() {
                var width = window.innerWidth; //获取页面可视化区域宽度
                width = Math.max(320, width);
                width = Math.min(750, width); //设置最大最小页面宽度
                document.documentElement.style.fontSize = width / 15 + 'px'; //设置html字体大小
            }
            window.onresize();
        })()
    </script>
</body>

</html>